home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / src / variables.h < prev    next >
C/C++ Source or Header  |  1996-10-30  |  5KB  |  186 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_variables_h)
  24. #define octave_variables_h 1
  25.  
  26. class symbol_record;
  27. class symbol_table;
  28.  
  29. class tree_fvc;
  30. class tree_identifier;
  31. class tree_indirect_ref;
  32. class octave_value;
  33. class octave_value_list;
  34. class string_vector;
  35.  
  36. #include <string>
  37.  
  38. #include "ov.h"
  39.  
  40. struct builtin_mapper_function;
  41.  
  42. typedef int (*sv_Function)(void);
  43.  
  44. struct builtin_variable
  45. {
  46.   builtin_variable (const string& n, const octave_value& v, int iaf, int p,
  47.             int e, sv_Function svf, const string& h)
  48.     : name (n), value (v), install_as_function (iaf), protect (p),
  49.       eternal (e), sv_function (svf), help_string (h) { }
  50.  
  51.   string name;
  52.   octave_value value;
  53.   int install_as_function;
  54.   int protect;
  55.   int eternal;
  56.   sv_Function sv_function;
  57.   string help_string;
  58. };
  59.  
  60. class
  61. octave_variable_reference
  62. {
  63. public:
  64.  
  65.   octave_variable_reference (tree_identifier *i) : id (i), indir (0) { }
  66.  
  67.   octave_variable_reference (tree_indirect_ref *i);
  68.  
  69.   ~octave_variable_reference (void) { }
  70.  
  71.   void assign (const octave_value&);
  72.  
  73.   void assign (const octave_value_list&, const octave_value&);
  74.  
  75.   octave_value value (void);
  76.  
  77. private:
  78.  
  79.   tree_identifier *id;
  80.  
  81.   tree_indirect_ref *indir;
  82.  
  83.   // No copying!
  84.  
  85.   octave_variable_reference (const octave_variable_reference&);
  86.  
  87.   octave_variable_reference& operator = (const octave_variable_reference&);
  88. };
  89.  
  90. typedef octave_value_list (*Octave_builtin_fcn)(const octave_value_list&, int);
  91.  
  92. struct builtin_function
  93. {
  94.   builtin_function (const string& n, int itf, Octave_builtin_fcn f,
  95.             const string& h)
  96.     : name (n), is_text_fcn (itf), fcn (f), help_string (h) { }
  97.  
  98.   string name;
  99.   int is_text_fcn;
  100.   Octave_builtin_fcn fcn;
  101.   string help_string;
  102. };
  103.  
  104. extern void initialize_symbol_tables (void);
  105.  
  106. extern bool lookup (symbol_record *s, int exec_script = 1);
  107.  
  108. extern symbol_record *lookup_by_name (const string& nm, int exec_script = 1);
  109.  
  110. extern string get_help_from_file (const string& f);
  111.  
  112. extern string builtin_string_variable (const string&);
  113. extern int builtin_real_scalar_variable (const string&, double&);
  114. extern octave_value builtin_any_variable (const string&);
  115.  
  116. extern void link_to_global_variable (symbol_record *sr);
  117. extern void link_to_builtin_variable (symbol_record *sr);
  118. extern void link_to_builtin_or_function (symbol_record *sr);
  119.  
  120. extern void force_link_to_function (const string&);
  121.  
  122. extern bool is_builtin_variable (const string&);
  123. extern bool is_text_function_name (const string&);
  124. extern bool is_mapper_function_name (const string&);
  125. extern bool is_builtin_function_name (const string&);
  126. extern bool is_globally_visible (const string&);
  127.  
  128. extern tree_fvc *is_valid_function (const octave_value&, const string&,
  129.                     int warn = 0); 
  130.  
  131. extern string_vector make_name_list (void);
  132.  
  133. extern void install_builtin_mapper (const builtin_mapper_function& mf);
  134.  
  135. extern void install_builtin_function (const builtin_function& gf);
  136.  
  137. extern void install_builtin_variable (const builtin_variable& v);
  138.  
  139. extern void
  140. install_builtin_variable_as_function (const string& name,
  141.                       const octave_value& val,
  142.                       int protect = 0, int eternal = 0,
  143.                       const string& help = string ());
  144.  
  145. extern void alias_builtin (const string& alias, const string& name);
  146.  
  147. extern void bind_ans (const octave_value& val, int print);
  148.  
  149. extern void bind_global_error_variable (void);
  150.  
  151. extern void clear_global_error_variable (void *);
  152.  
  153. extern void bind_builtin_variable (const string&, const octave_value&,
  154.                    int protect = 0, int eternal = 0,
  155.                    sv_Function f = (sv_Function) 0,
  156.                    const string& help = string ());
  157.  
  158. extern void install_builtin_variables (void);
  159.  
  160. // Symbol table for symbols at the top level.
  161. extern symbol_table *top_level_sym_tab;
  162.  
  163. // Symbol table for the current scope.
  164. extern symbol_table *curr_sym_tab;
  165.  
  166. // Symbol table for global symbols.
  167. extern symbol_table *global_sym_tab;
  168.  
  169. enum echo_state
  170. {
  171.   ECHO_OFF = 0,
  172.   ECHO_SCRIPTS = 1,
  173.   ECHO_FUNCTIONS = 2,
  174.   ECHO_CMD_LINE = 4
  175. };
  176.  
  177. extern int Vecho_executing_commands;
  178.  
  179. #endif
  180.  
  181. /*
  182. ;;; Local Variables: ***
  183. ;;; mode: C++ ***
  184. ;;; End: ***
  185. */
  186.